package web.utils;

import java.io.File;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import main.TankSicherheit;

/**
 * Application Lifecycle Listener implementation class BasicConfig
 *
 */
public class BasicConfig implements ServletContextListener {

	private TankSicherheit ts=null;
    /**
     * Default constructor. 
     */
    public BasicConfig() 
    {
    	
    }
    
    private void init()
    {
    	ts = new TankSicherheit();
 
    	try
    	{
    		File fini = new File("TaSi.ini");
    		if(fini.exists())
    		{
    			
    		}
    		else
    		{
    			
    		}
    		System.out.println(fini.getAbsolutePath());
    		
    		
    		
    	}
    	catch(Exception e)
    	{
    		e.printStackTrace();
    	}
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent arg0) {
    	System.out.println("context init");
    	TankSicherheit.servletContext=arg0.getServletContext();
        init();
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
    	System.out.println("context destroyed");
    	if(ts!=null)
    	{
    		System.out.println("shutting down TankSicherheit");
    		ts.shutdown();
    	}
        
    }
	
}
